import logging
from . import ROOT_DIR
from . import configuration

logging.basicConfig(
    level=getattr(logging, configuration["fastapi"]["log"]["level"]),  # 设置日志级别
    format="%(asctime)s - %(levelname)s - %(message)s",  # 设置日志格式
    datefmt="%Y-%m-%d %H:%M:%S",  # 设置日期格式
    handlers=[
        logging.StreamHandler(),  # 将日志输出到控制台
        logging.FileHandler(
            (ROOT_DIR / "log" / "app.log").as_posix()
        ),  # 将日志输出到文件
    ],
)
